#include <iostream>
using namespace std;

int main() {
    int T; cin >> T;
    int a, b;
    for (int i = 0; i < T; ++i) {
        cin >> a >> b;
        int ans;
        if(a == b) ans = 0;
        else{
            if((a%2 && b%2) || (a%2==0 && b%2==0)){
                if(a<b) ans = 2;
                else ans = 1;
            }else{
                if(a<b) ans = 1;
                else ans = 2;
            }
        }
        cout << ans << "\n";

    }
    return 0;
}
